﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;
using Huirui.Cavan.Domain.MainBoundedContext.SalesModule;
using Huirui.Cavan.Domain.MainBoundedContext.StockModule;
using System.Collections.Generic;
using Huirui.Cavan.Domain.Seedwork;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Customer

    /// <summary>
    /// Customer object for NHibernate mapped table 'Customer'.
    /// </summary>
    [Serializable]
    public class Customer : Persistent<string>
    {
        #region Member Variables

        protected SystemIdentifier.AgentType _agentType;
        protected string _name;
        protected SystemIdentifier.CustomerNature _nature;
        protected string _deliveryAddress;
        protected string _contact;
        protected string _telephone;
        protected string _mobile;
        protected string _fax;
        protected string _email;
        protected Area _area;
        protected Corporation _corporation;
        protected string _address;
        protected string _addressEnglish;
        protected string _deliveryAddress1;
        protected string _deliveryAddress2;
        protected string _postCode;
        protected SystemIdentifier.PayType _payType;
        protected decimal _discountRate;
        protected int _payDay;
        protected decimal _creditLimit;
        protected string _taxIdentificationNumber;
        protected SystemIdentifier.InvoiceType _invoiceType;
        protected string _bank;
        protected string _bankAccount;
        protected string _remark;
        protected bool _status;
        protected WareHouse _wareHouse;
        protected Role _employeeRole;
        protected IList<Receivables> _receivableses;
        protected IList<Receipt> _receipts;
        protected IList<Sale> _sales;
        protected IList<SalesOrder> _salesOrders;
        protected IList<SalesReturn> _salesReturns;
        protected IList<StockOutApply> _stockOutApplies;
        protected IList<SalesPrice> _salesPrices;
        
        #endregion

        #region Constructors

        public Customer() { }

        public Customer(string id, SystemIdentifier.AgentType agentType, string name, SystemIdentifier.CustomerNature nature, string deliveryAddress, string contact, string telephone, string mobile, string fax, string email, Area area, string address, string addressEnglish, string deliveryAddress1, string deliveryAddress2, string postCode, SystemIdentifier.PayType payType, decimal discountRate, int payDay, decimal creditLimit, string taxIdentificationNumber, SystemIdentifier.InvoiceType invoiceType, string bank, string bankAccount, string remark, bool status, DateTime createDate, DateTime modifyDate, int editUser, Role employeeRole, Corporation corporation, WareHouse wareHouse)
        {
            this.Id = id;
            this._agentType = agentType;
            this._name = name;
            this._nature = nature;
            this._deliveryAddress = deliveryAddress;
            this._contact = contact;
            this._telephone = telephone;
            this._mobile = mobile;
            this._fax = fax;
            this._email = email;
            this._area = area;
            this._address = address;
            this._addressEnglish = addressEnglish;
            this._deliveryAddress1 = deliveryAddress1;
            this._deliveryAddress2 = deliveryAddress2;
            this._postCode = postCode;
            this._payType = payType;
            this._discountRate = discountRate;
            this._payDay = payDay;
            this._creditLimit = creditLimit;
            this._taxIdentificationNumber = taxIdentificationNumber;
            this._invoiceType = invoiceType;
            this._bank = bank;
            this._bankAccount = bankAccount;
            this._remark = remark;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._employeeRole = employeeRole;
            this._corporation = corporation;
            this._wareHouse = wareHouse;
            this._status = status;
        }

        #endregion

        #region Public Properties


        public virtual SystemIdentifier.AgentType AgentType
        {
            get { return _agentType; }
            set { _agentType = value; }
        }

        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual SystemIdentifier.CustomerNature Nature
        {
            get { return _nature; }
            set { _nature = value; }
        }

        public virtual string DeliveryAddress
        {
            get { return _deliveryAddress; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress", value, value.ToString());
                _deliveryAddress = value;
            }
        }

        public virtual string Contact
        {
            get { return _contact; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Contact", value, value.ToString());
                _contact = value;
            }
        }

        public virtual string Telephone
        {
            get { return _telephone; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Telephone", value, value.ToString());
                _telephone = value;
            }
        }

        public virtual string Mobile
        {
            get { return _mobile; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Mobile", value, value.ToString());
                _mobile = value;
            }
        }

        public virtual string Fax
        {
            get { return _fax; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Fax", value, value.ToString());
                _fax = value;
            }
        }

        public virtual string Email
        {
            get { return _email; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Email", value, value.ToString());
                _email = value;
            }
        }

        public virtual Area Area
        {
            get { return _area; }
            set { _area = value; }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual string Address
        {
            get { return _address; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for Address", value, value.ToString());
                _address = value;
            }
        }

        public virtual string AddressEnglish
        {
            get { return _addressEnglish; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for AddressEnglish", value, value.ToString());
                _addressEnglish = value;
            }
        }

        public virtual string DeliveryAddress1
        {
            get { return _deliveryAddress1; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress1", value, value.ToString());
                _deliveryAddress1 = value;
            }
        }

        public virtual string DeliveryAddress2
        {
            get { return _deliveryAddress2; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress2", value, value.ToString());
                _deliveryAddress2 = value;
            }
        }

        public virtual string PostCode
        {
            get { return _postCode; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for PostCode", value, value.ToString());
                _postCode = value;
            }
        }

        public virtual SystemIdentifier.PayType PayType
        {
            get { return _payType; }
            set { _payType = value; }
        }

        public virtual decimal DiscountRate
        {
            get { return _discountRate; }
            set { _discountRate = value; }
        }

        public virtual int PayDay
        {
            get { return _payDay; }
            set { _payDay = value; }
        }

        public virtual decimal CreditLimit
        {
            get { return _creditLimit; }
            set { _creditLimit = value; }
        }

        public virtual string TaxIdentificationNumber
        {
            get { return _taxIdentificationNumber; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for TaxIdentificationNumber", value, value.ToString());
                _taxIdentificationNumber = value;
            }
        }

        public virtual SystemIdentifier.InvoiceType InvoiceType
        {
            get { return _invoiceType; }
            set { _invoiceType = value; }
        }

        public virtual string Bank
        {
            get { return _bank; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Bank", value, value.ToString());
                _bank = value;
            }
        }

        public virtual string BankAccount
        {
            get { return _bankAccount; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for BankAccount", value, value.ToString());
                _bankAccount = value;
            }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual bool Status
        {
            get { return _status; }
            set
            {
                _status = value;
            }
        }

        public virtual Role EmployeeRole
        {
            get { return _employeeRole; }
            set { _employeeRole = value; }
        }

        public virtual IList<Receivables> Receivableses
        {
            get
            {
                if (_receivableses == null)
                {
                    _receivableses = new List<Receivables>();
                }
                return _receivableses;
            }
            set { _receivableses = value; }
        }

        public virtual IList<Receipt> Receipts
        {
            get
            {
                if (_receipts == null)
                {
                    _receipts = new List<Receipt>();
                }
                return _receipts;
            }
            set { _receipts = value; }
        }

        public virtual IList<Sale> Sales
        {
            get
            {
                if (_sales == null)
                {
                    _sales = new List<Sale>();
                }
                return _sales;
            }
            set { _sales = value; }
        }

        public virtual IList<SalesOrder> SalesOrders
        {
            get
            {
                if (_salesOrders == null)
                {
                    _salesOrders = new List<SalesOrder>();
                }
                return _salesOrders;
            }
            set { _salesOrders = value; }
        }

        public virtual IList<SalesReturn> SalesReturns
        {
            get
            {
                if (_salesReturns == null)
                {
                    _salesReturns = new List<SalesReturn>();
                }
                return _salesReturns;
            }
            set { _salesReturns = value; }
        }

        public virtual IList<StockOutApply> StockOutApplies
        {
            get
            {
                if (_stockOutApplies == null)
                {
                    _stockOutApplies = new List<StockOutApply>();
                }
                return _stockOutApplies;
            }
            set { _stockOutApplies = value; }
        }

        public virtual WareHouse WareHouse
        {
            get { return _wareHouse; }
            set { _wareHouse = value; }
        }

        public virtual IList<SalesPrice> SalesPrices
        {
            get { return _salesPrices; }
            set { _salesPrices = value; }
        }
        #endregion
    }
    #endregion
}